<?php
/**
 * Created by PhpStorm.
 * User: 何培春
 * Date: 2017/8/13
 * Time: 1:39
 */

/**
 * @return string 浏览器的IP地址
 */
function GetIp(){
    if (getenv('HTTP_CLIENT_IP')) {
        $ip = getenv('HTTP_CLIENT_IP');
    }
    elseif (getenv('HTTP_X_FORWARDED_FOR')) {
        $ip = getenv('HTTP_X_FORWARDED_FOR');
    }
    elseif (getenv('HTTP_X_FORWARDED')) {
        $ip = getenv('HTTP_X_FORWARDED');
    }
    elseif (getenv('HTTP_FORWARDED_FOR')) {
        $ip = getenv('HTTP_FORWARDED_FOR');

    }
    elseif (getenv('HTTP_FORWARDED')) {
        $ip = getenv('HTTP_FORWARDED');
    }
    else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
}




function If_Login(){
    if(!If_Login_Session()){//发现session有空,则清除登陆信息
       return false;
    }else{
        return true;
    }
}
function Login_Out(){
    session('uid',null);
    session('name',null);
}
function If_Login_Session(){
    if(!session('uid')) {
        return false;
    }
    if(!session('name')) {
        return false;
    }
    return true;
}

